package main

import (
	"os"
	"text/template"
)

// 点号和with-end
// with将点号设为管道的值, 若管道为空, 则with-end之间的值将被忽略

func main() {
	tmpl := template.New("test")
	// will print "[[ Hello ]]!"
	tmpl = template.Must(tmpl.Parse("{{with `Hello`}} [[ {{.}} ]]{{end}}!"))
	tmpl.Execute(os.Stdout, nil)

	// will print "Hello  Hanmaimai"
	t, _ := tmpl.Parse("{{with `Hello`}}{{.}} {{with `Hanmaimai`}} {{.}}{{end}}{{end}}")
	t.Execute(os.Stdout, nil)
}
